package com.jxm.quartzdemo.domain;

import org.quartz.*;

//多次调用 Job 的时候，将参数保留在 JobDataMap
@PersistJobDataAfterExecution
public class JobStatus implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
//        Object a = context.getTrigger().getJobDataMap().get("count");
//        System.out.println("===="+a);
        JobDataMap dataMap = context.getMergedJobDataMap();
        Object count1 = dataMap.get("count");
        System.out.println("--------------------"+count1);

        long count = (long) context.getJobDetail().getJobDataMap().get("count");
        System.out.println("当前执行，第" + count + "次");
        context.getJobDetail().getJobDataMap().put("count", ++count);
    }
}